/****************************************************
 * @file: communication.h
 * @brief: 生成、分析数据
 * @author: 廖文雄 
 * @date: 2019.07.27
 * @note: 
 ****************************************************/
#ifndef __COMMUNICATION_H
#define __COMMUNICATION_H

enum COMMOND {
    REQUEST = 1,
    FALSE_REQUEST,

    RESPONSE,
    ACK_RESPONSE,
    FALSE_RESPONSE,

    PRINT_NORMAL,
    PRINT_REVERSE,
    ACK_DATA,
    FALSE_DATA,
};

enum STATE {
    BUILD_FIFO = 1,
    BAG_BUILD,
    BAG_SEND,
    BAG_REVICE,
    BAG_ANALYSIS,
    FINISH
};

//命令码
#define CODE_REQUEST            (0x01)
#define CODE_FALSE_REQUEST      (0x02)

#define CODE_RESPONSE           (0x03)
#define CODE_ACK_RESPONSE       (0x04)
#define CODE_FALSE_RESPONSE     (0x05)

#define CODE_NORMAL             (0x06)
#define CODE_REVERSE            (0x07)
#define CODE_ACK_DATA           (0x08)
#define CODE_FALSE_DATA         (0x09)


#define HEAD    (0xAA)
#define END     (0x55)

#define FALSE       (-1)
#define TRUE        (0)
#define BAG_DATA    (6)
#define BAG_COMMOND (4)


#define FIFO_NAME "/tmp/my_fifo2"

extern char *build_data(int type);
extern int analysis_data(char *data);
extern int analysis_verify(char *get_data);

#endif
